<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<th:block th:include="include/src :: grid_base_js_and_css"/>
	
	<style>
	html {height: 100vh;background-color: #ffffff;}
	body {height: 100vh;}
	</style>
</head>
<body>
<!-- 字段名称 -->
<script type="text/html" id="templet_script_name">
<input type="text" class="layui-input ys-input-table" name="name" value="{{d.name}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 字段编码 -->
<script type="text/html" id="templet_script_code">
<input type="text" class="layui-input ys-input-table" name="code" value="{{d.code}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 显示类型 -->
<script type="text/html" id="templet_script_frontType">
<select name="frontType" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_GridCol-FrontType'], function(index, item){ }}
{{# if(d.frontType == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 是否编辑 -->
<script type="text/html" id="templet_script_frontEdit">
{{# if(d.frontEdit === 1){ }}
<input type="checkbox" name="frontEdit" value="{{d.frontEdit}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="frontEdit" value="{{d.frontEdit}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>
<!-- 是否显示 -->
<script type="text/html" id="templet_script_frontShow">
{{# if(d.frontShow === 1){ }}
<input type="checkbox" name="frontShow" value="{{d.frontShow}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
{{#  } else { }}
<input type="checkbox" name="frontShow" value="{{d.frontShow}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
{{#  } }}
</script>

<!-- 是否合并 -->
<script type="text/html" id="templet_script_isRowspan">
	{{# if(d.isRowspan === 1){ }}
	<input type="checkbox" name="isRowspan" value="{{d.isRowspan}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
	{{#  } else { }}
	<input type="checkbox" name="isRowspan" value="{{d.isRowspan}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
	{{#  } }}
</script>

<!-- 是否合计 -->
<script type="text/html" id="templet_script_totalRow">
	{{# if(d.totalRow === 1){ }}
	<input type="checkbox" name="totalRow" value="{{d.totalRow}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table" checked>
	{{#  } else { }}
	<input type="checkbox" name="totalRow" value="{{d.totalRow}}" lay-skin="switch" lay-text="是|否" lay-filter="_input_filter_checkbox_on_menu_table">
	{{#  } }}
</script>
<!-- 前台宽度 -->
<script type="text/html" id="templet_script_frontWidth">
<input type="text" class="layui-input ys-input-table" name="frontWidth" value="{{d.frontWidth}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 对齐方式 -->
<script type="text/html" id="templet_script_frontAlign">
<select name="frontAlign" lay-filter="_input_filter_selector_on_table">
{{#  layui.each(MAP_DICT['YS_Col-FrontAlign'], function(index, item){ }}
{{# if(d.frontAlign == item.value){ }} <option value="{{ item.value }}" selected>{{ item.name }}</option> {{#  } else { }} <option value="{{ item.value }}">{{ item.name }}</option>  {{#  } }}
{{#  }); }}
</select>
</script>
<!-- 触发联动字段 -->
<script type="text/html" id="templet_script_modalRelativeCode">
<input type="text" class="layui-input ys-input-table" name="modalRelativeCode" value="{{d.modalRelativeCode}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 弹出框取值字段 -->
<script type="text/html" id="templet_script_modalValueCode">
<input type="text" class="layui-input ys-input-table" name="modalValueCode" value="{{d.modalValueCode}}" lay-skin="input" lay-filter="_input_filter_text_on_table" lay-event="_event_text_change_on_table">
</script>
<!-- 操作 -->
<script type="text/html" id="templet_script_12438">
{{#  if(d.frontType == 't_checkbox' || d.frontType == 't_dropdown'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置选项',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysGridCol/toSettingOption?id={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置选项</a>
{{#  } }}
{{#  if(d.frontType == 't_buttontext' || d.frontConditionType == 't_buttontext' || d.formAddType == 't_buttontext' || d.formEditType == 't_buttontext'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置前台弹出框',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysGridCol/toSettingSelectorModal?id={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置弹出框</a>
{{#  } }}
{{#  if(d.frontType == 't_file_multy'){ }}
<a class="layui-btn layui-btn-xs layui-btn-normal" onclick="var w=($(window).width()*0.8); var h=($(window).height() - 50); layer.open({ title:'设置文件来源类型',  type: 2,area: [w+'px', h +'px'],fix: true, maxmin: false, shadeClose: true, shade:0.4,shade:0.5,content:'/web/sys/ysGridCol/toSettingMultyFileSourceType?id={{d.id}}' });"><i class="layui-icon layui-icon-set"></i>设置文件来源</a>
{{#  } }}
<a class="layui-btn layui-btn-xs layui-btn-danger" onclick="doDeleteOnTable('/api/inter/ysGridCol/deleteTrue?id={{d.id}}');"><i class="layui-icon layui-icon-delete"></i>删除</a>
</script>
	<div class="display_flex" style="height: 100%;" id="id_panel_content">
	</div>
	
	<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="_subgrid_event-add-row"><i class="iconfont icon-add-btn"></i>新增单个字段</a>
		<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="_subgrid_event-add-rows"><i class="iconfont icon-add-btn"></i>批量新增字段</a>
	</div>
	</script>
	
	<script th:inline="javascript">
	var cols = [
	            [
	             {
	                 "title": "",
	                 "type": "checkbox",
	                 "fixed": "left",
	                 "unresize": true,
	                 "width": "40",
	                 "colGroup": false
	             },
	             {
	                 "title": "序号",
	                 "fixed": "left",
	                 "unresize": true,
	                 "width": "50",
	                 "align": "center",
	                 "type": "numbers"
	             },
	             {
	                 "title": "字段ID",
	                 "field": "id",
	                 "fixed": "left",
	                 "width": "80",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal"
	             },
	             {
	                 "title": "字段名称",
	                 "field": "name",
	                 "fixed": "left",
	                 "width": "160",
	                 "align": "center",
	                 "type": "normal",
	                 "templet": '#templet_script_name'
	             },
	             {
	                 "title": "字段编码",
	                 "field": "code",
	                 "fixed": "left",
	                 "width": "200",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_code'
	             },
	             {
	                 "title": "显示类型",
	                 "field": "frontType",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_frontType'
	             },
	             {
	                 "title": "是否编辑",
	                 "field": "frontEdit",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_frontEdit'
	             },
	             {
	                 "title": "是否显示",
	                 "field": "frontShow",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_frontShow'
	             },
				 {
					 "title": "是否行合并",
					 "field": "isRowspan",
					 "width": "120",
					 "align": "center",
					 "sort": true,
					 "type": "normal",
					 "templet": '#templet_script_isRowspan'
				 },
				 {
					 "title": "是否合计",
					 "field": "totalRow",
					 "width": "120",
					 "align": "center",
					 "sort": true,
					 "type": "normal",
					 "templet": '#templet_script_totalRow'
				 },
	             {
	                 "title": "显示宽度",
	                 "field": "frontWidth",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_frontWidth'
	             },
	             {
	                 "title": "对齐方式",
	                 "field": "frontAlign",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_frontAlign'
	             },
	             {
	                 "title": "触发联动字段",
	                 "field": "modalRelativeCode",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_modalRelativeCode'
	             },
	             {
	                 "title": "弹出框取值字段",
	                 "field": "modalValueCode",
	                 "width": "120",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": '#templet_script_modalValueCode'
	             },
	             {
	                 "title": "操作",
	                 "field": "ope",
	                 "fixed": "right",
	                 "width": "300",
	                 "align": "center",
	                 "sort": true,
	                 "type": "normal",
	                 "templet": "#templet_script_12438"
	             }
	         ]
	     ];
	// 搜索表单初始化
	var gridObj = null;
	//使用layui的模块
	layui.config({
		//自定义layui组件的目录,设定扩展的layui模块的所在目录，一般用于外部模块扩展
		base: '/static/js/layui_extends/'
	}).use(['form', 'jquery', 'element', 'table', 'dropdown', 'optimizeSelectOption', 'util', 'laydate', 'YsGridOfMainTable', 'YsModal'], function(){
		var $ = layui.jquery;
		var dropdown = layui.dropdown;
		var element = layui.element;
		var form = layui.form;
		var laydate = layui.laydate;
		var table = layui.table;
		var util = layui.util;
		var YsGridOfMainTable = layui.YsGridOfMainTable;
		gridObj = YsGridOfMainTable.init({
			id_panel_content: 'id_panel_content',
			conditions: [],
			menuId: [(${id})], // 菜单ID
			templateType: 'normal_list', // 模板类型，见ENUM
			pathGridRequest: '/api/inter/ysGridCol/search?gridId=[(${gridId})]', // 表格数据请求地址
			pathGridEditRequest: '/api/inter/common/editOnTable?menuId=10191', // 表格上编辑提交地址
			cols: cols,
			sortType: 3
		});
	});
	
	// 在表格上修改
	function doEditOnTable(dataCommit) {
		var indexOfLoading = layer.load(1, {
			shade: [0.5,'#000000'] //0.1透明度的白色背景
		});
		$.post('/api/inter/common/editOnTable?menuId=[(${id})]', dataCommit, function(res){
			if (res.code == 0) {
				layer.msg(res.msg);
				layer.close(indexOfLoading);
			} else {
				layer.close(indexOfLoading);
				layer.msg(res.msg);
			}
		});
	}
	
	// 调整鼠标移动到每行数据时的样式
	$('body').on("mouseenter",".layui-table-body tr",function () {
	    $(this).siblings().find("div").css("color","#142A48");
	    $(this).find("div").css("color","#4DA1FF");
	})
	</script>
</body>
</html>